/*     */ package com.wgcloud.service;
/*     */ 
/*     */ import com.wgcloud.entity.AppInfo;
/*     */ import com.wgcloud.entity.DeskState;
/*     */ import com.wgcloud.entity.DockerInfo;
/*     */ import com.wgcloud.entity.PortInfo;
/*     */ import com.wgcloud.entity.SystemInfo;
/*     */ import com.wgcloud.service.AppInfoService;
/*     */ import com.wgcloud.service.DeskStateService;
/*     */ import com.wgcloud.service.DockerInfoService;
/*     */ import com.wgcloud.service.PortInfoService;
/*     */ import com.wgcloud.service.SystemInfoService;
/*     */ import com.wgcloud.util.DateUtil;
/*     */ import com.wgcloud.util.FormatUtil;
/*     */ import java.math.BigDecimal;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.lang3.StringUtils;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Service;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ 
/*     */ 
/*     */ @Service
/*     */ public class TaskUtilService
/*     */ {
/*  31 */   private Logger logger = LoggerFactory.getLogger(com.wgcloud.service.TaskUtilService.class);
/*     */   
/*     */   @Autowired
/*     */   SystemInfoService systemInfoService;
/*     */   
/*     */   @Autowired
/*     */   AppInfoService appInfoService;
/*     */   
/*     */   @Autowired
/*     */   DockerInfoService dockerInfoService;
/*     */   
/*     */   @Autowired
/*     */   PortInfoService portInfoService;
/*     */   
/*     */   @Autowired
/*     */   DeskStateService deskStateService;
/*     */ 
/*     */   
/*     */   @Transactional
/*     */   public void refreshCommitDate() throws Exception {
/*  51 */     Date nowDate = DateUtil.getNowTime();
/*  52 */     this.logger.info("刷新监控数据更新时间：" + nowDate);
/*  53 */     Map<String, Object> params = new HashMap<>();
/*  54 */     params.put("state", "1");
/*  55 */     List<SystemInfo> systemInfolist = this.systemInfoService.selectAllByParams(params);
/*  56 */     for (SystemInfo systemInfo : systemInfolist) {
/*  57 */       systemInfo.setCreateTime(nowDate);
/*     */     }
/*  59 */     this.systemInfoService.updateRecord(systemInfolist);
/*  60 */     List<AppInfo> appInfolist = this.appInfoService.selectAllByParams(params);
/*  61 */     for (AppInfo appInfo : appInfolist) {
/*  62 */       appInfo.setCreateTime(nowDate);
/*     */     }
/*  64 */     this.appInfoService.updateRecord(appInfolist);
/*  65 */     List<DockerInfo> dockerInfolist = this.dockerInfoService.selectAllByParams(params);
/*  66 */     for (DockerInfo dockerInfo : dockerInfolist) {
/*  67 */       dockerInfo.setCreateTime(nowDate);
/*     */     }
/*  69 */     this.dockerInfoService.updateRecord(dockerInfolist);
/*  70 */     List<PortInfo> portInfolist = this.portInfoService.selectAllByParams(params);
/*  71 */     for (PortInfo portInfo : portInfolist) {
/*  72 */       portInfo.setCreateTime(nowDate);
/*     */     }
/*  74 */     this.portInfoService.updateRecord(portInfolist);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String sumDiskSizeCache() throws Exception {
/*  85 */     Map<String, Object> params = new HashMap<>();
/*     */     
/*  87 */     List<DeskState> deskStateList = this.deskStateService.selectAllByParams(params);
/*  88 */     BigDecimal sumSize = new BigDecimal(0);
/*  89 */     for (DeskState deskState : deskStateList) {
/*  90 */       if (!StringUtils.isEmpty(deskState.getSize())) {
/*     */         try {
/*  92 */           sumSize = sumSize.add(new BigDecimal(deskState.getSize().replace("G", "")));
/*  93 */         } catch (Exception e) {
/*  94 */           this.logger.error("double类型转换错误：", e);
/*     */         } 
/*     */       }
/*     */     } 
/*  98 */     String sumSizeStr = String.valueOf(sumSize);
/*  99 */     if (sumSizeStr.indexOf(".") > 0) {
/* 100 */       sumSizeStr = sumSizeStr.substring(0, sumSizeStr.lastIndexOf("."));
/*     */     }
/* 102 */     return FormatUtil.gToT(sumSizeStr);
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/service/TaskUtilService.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */